﻿<!DOCTYPE html>
<html>
    <head>
        <script type="application/javascript" src="lib/jquery-1.4.2.min.js"></script>
        <title></title>
        <script type="text/javascript">
            var rendered = false;
            function printSource(o){
                $('#output').html('<h1>' + o.location + '</h1>');
                listItems(o, 'styles', 'CSS stylesheets', '#output');
                listItems(o, 'scripts', 'Javascript files', '#output');
                rendered = true;
            }
            
            function listItems(o, id, name, el){
                var html = '<h2>' + name + '</h2>', ul = $('<ul></ul>').appendTo(el);
                $.each(o[id], function(i, s){
                    if (s.url) {
						html += '<li><a href="' + s.url + '">' + s.url + '</a></li>';
					}
                    if (s.code) {
						html += '<li><code>' + htmlEscape(s.code) + '</code></li>';
					}
                });
                ul.append(html);
            }
            
            
            function req(message, cb, data){
                if (chrome.extension) {
                    var o = data || {};
                    o.message = message;
                    chrome.extension.sendRequest(o, cb);
                }
            }
			
			function htmlEscape(txt){
				return txt.replace(/>/g, '&gt;').replace(/</g, '&lt;');
			} 
            /*
            function refresh(){
                console.log("refresh");
                //get id from uid
                var id = window.location.hash.replace(/^#/, '');
                req('getdata', function(o){
                    printSource(o);
                }, {
                    id: id
                });
            }
            
            $(document).ready(function(){
                $('#refresh').bind('click', refresh);
            });
            window.setTimeout(function(){
                if (!rendered) {
                    refresh();
                }
            }, 500);*/
        </script>
    </head>
    <body>
        <!-- <button id="refresh">
            Refresh
        </button> -->
        <div id="output">
        </div>
    </body>
</html>
